struct mkshort_handle_imp; // forward declare, definition in mkshort.cc
using short_handle = mkshort_handle_imp*;
-char* mkshort(short_handle, const char*, bool);
-QString mkshort(short_handle, const QString&);
+QByteArray mkshort(short_handle, const char*, bool);
+QString mkshort(short_handle, const QString&);
short_handle mkshort_new_handle();
QString mkshort_from_wpt(short_handle h, const Waypoint* wpt);
void mkshort_del_handle(short_handle* h);
* mkshort will do collision detection and namespace
* cleaning
*/
- char* ident = mkshort(mkshort_handle,
- global_opts.synthesize_shortnames ?
- str_from_unicode(src).constData() :
- str_from_unicode(wpt->shortname).constData(),
- false);
+ QByteArray ident = mkshort(mkshort_handle,
+ global_opts.synthesize_shortnames ?
+ str_from_unicode(src).constData() :
+ str_from_unicode(wpt->shortname).constData(),
+ false);
/* Should not be a strcpy as 'ident' isn't really a C string,
* but rather a garmin "fixed length" buffer that's padded
* to the end with spaces. So this is NOT (strlen+1).
*/
- write_char_string(tx_waylist[i]->ident, ident, sizeof(tx_waylist[i]->ident));
-
- if (global_opts.synthesize_shortnames) {
- xfree(ident);
- }
+ write_char_string(tx_waylist[i]->ident, ident.constData(), sizeof(tx_waylist[i]->ident));
// If we were explicitly given a comment from GPX, use that.
// This logic really is horrible and needs to be untangled.
hdl->must_uniq = i;
}
-char*
+QByteArray
mkshort(short_handle h, const char* istring, bool is_utf8)
{
char* ostring;
}
if (hdl->must_uniq) {
- return mkshort_add_to_list(hdl, ostring);
+ ostring = mkshort_add_to_list(hdl, ostring);
}
- return ostring;
+ QByteArray rval(ostring);
+ xfree(ostring);
+ return rval;
}
QString
mkshort(short_handle h, const QString& istring)
{
- char* t = mkshort(h, CSTR(istring), true);
- QString r(t);
- xfree(t);
- return r;
+ return mkshort(h, CSTR(istring), true);
}
/*